package com.smile.db.operation;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.google.gson.Gson;
import com.smile.db.DBHelper;
import com.smile.model.SendString;

public class test {
	private String number = "2016072110022";
	private String password = "123456789";
	private String name = "1111";
	
	public boolean start() {
//		String sql = "select u_passwor from user where u_name='" + number
//				+ "'";
//		ResultSet result = DBHelper.query(sql);
//		try {
//			if (result.next()) {
//				if (result.getString(1).equals(password)) {
//
//					return true;
//				} else {
//					System.out.println("密码错误！");
//
//					return false;
//				}
//			} else {
//				System.out.println("查无此用户！");
//
//				return false;
//			}
//		} catch (SQLException e) {
//			System.out.println(e.getMessage());
//			System.out.println("查询失败！");
//
//			return false;
//		}
		
		String sql = "INSERT INTO `user` (`u_id`, `u_name`, `u_nickname`, `u_password`) VALUES (NULL,'" + number
				+ "','" + name + "', '" + password +  "')";
//		System.out.println(sql);
		int result = -1;
		try {
			result = DBHelper.update(sql);
		} catch (SQLException e) {
//			e.printStackTrace();
			System.out.println(e.getErrorCode());
			System.out.println(e.getMessage());
			return false;
		}
		System.out.println(result);
		return true;
		
		
	}
	
	
	public static void main(String[] args){
		boolean is = new test().start();
		System.out.println(is);
		
//		SendString returnString = new SendString(102, 2, "{'name':'小熊'}");
//		String jsonString = new Gson().toJson(returnString);
//		SendString r = new Gson().fromJson(jsonString, SendString.class);
//		System.out.println(jsonString);
//		System.out.println(r.toString());
		
	}
	
}
